
// 'use strict'
const commomObject = {
    enumerable: true,
    configurable: true,
    get: undefined,
    set: undefined
}

commomObject.get = () => {
    console.log(this);
    return ''
}

commomObject.get();


let aString = 'asdfghjklaa'

function handle (str,alf){
    let sortArr = str.split(alf).map(el => el.length)
    let longst = sortArr.length > 2 ?sortArr.sort().pop() : 0
    return longst
}


let setArr = Array.from(new Set(aString.split('')))
let longst = setArr.map(el => handle(aString,el)).sort().pop()

console.log(1111,longst);

var a= a;
console.log('a:',a);
// let c = c;
console.log('varaa:',aa);

function aa() {let aa =0;console.log('myaa:',this);};
console.log('varaa:',aa);
aa();//global对象

(() => {
    if(true) {
        console.log('varaa:',aaa);
        if(false) {
            function aaa() {let aaa='mm';console.log('aaa',aaa);}
        }
    }
    // aaa();
    console.log('varaaa:',aaa);
})()

const bb = Object.freeze({ 0:1 , 1:2 , 2:3 });
// bb[0] = 4; 严格模式报错
console.log(bb);
// console.log(global.global)
var ff = 'sss'
console.log(global.ff); //{}

var getGlobal = function () {
    if (typeof self !== 'undefined') {console.log('self'); return self; }
    if (typeof window !== 'undefined') {console.log('window'); return window; }
    if (typeof global !== 'undefined') {console.log('global'); return global; }
    throw new Error('unable to locate global object');
  };
console.log(getGlobal());

console.log(globalThis);

function* fibs() {
    let a = 0;
    let b = 1;
    while (true) {
      yield a;
      [a, b] = [b, a + b];
    }
  }
  
  let [first, second, third, fourth, fifth, sixth] = fibs()
  console.log(second);

  let z = [
      {id:'123',name:'纸巾',price: 23.5},
      {id:'124',name:'电视',price: 1589},
      {id:'125',name:'筷子',price: 0.52},
  ];

  let zz = z.map(({price}) => {
    return price
  })
let {price} = {id:'123',name:'纸巾',price: 23.5}
  console.log(zz);

const map = new Map();
map.set('first', 'hello');
console.log(map);
// let {xx='xxx', yy = ()=>{}, zzz=[]}={xx:null, yy:undefined}
let xx=null,yy= ()=>{},zzz=[]
console.log(xx,yy,zzz);


let total = 30;
let msg = passthru`The total is ${total} (${total*1.05} with tax)`;

function passthru(literals) {
    let args =arguments instanceof Object
    console.log('arguments',arguments,args);
    console.log('literals:',literals);
    let result = '';
    let i = 0;

    while (i < literals.length) {
    result += literals[i++];
    if (i < arguments.length) {
        result += arguments[i];
    }
    }

  return result;
}
console.log(msg);

const str = 'someStrings   ';
let mun= str.indexOf('s',2);//0
let unm = str.lastIndexOf('s');//10
let str1 = str.slice(3,5);
let str2 = str.slice(-5,-1)
let str3 = str.replace(/s/g,'M')
let str4 = str.concat('aaaa','dddddd')
let str5 = str.trim()
let mmun = str.charCodeAt(0)
let arra = str.split()
console.log(mun,unm,str1,str2,str3,str4,str5,str,mmun,arra,'sss');

let my_arr = [1,2,3].entries();
console.log(Array.from(my_arr));

// let myObj1 = Object.create({a:'a'},{b:{enumrable:true,congfigurable:true,get(){
//     console.log('getssss');
//     return this.__proto__.a
// },set(val){
//     console.log(val);
//     this.__proto__.a = val
// }}})
// myObj1.b = 'mmm'
// setTimeout(() => {
//     console.log(myObj1.b);
// }, 1000);
let mmObj = {a:'aaa'}

Object.defineProperties(mmObj,{
    c:{
       value:'mmm',
       witable:true,
       enumrable:true,
       congfigurable:true  
    },
    b:{
         enumable:true,
         configrurable:true,
         get(){return this.a},
         set(val){ console.log(val,this);;this.a = val}
    }
})
console.log(mmObj.b);
mmObj.b = 5
console.log(mmObj,mmObj.a,mmObj.b);

let sealObj = {aa:'aa'}
Object.seal(sealObj);
sealObj.aa = 'bb';
console.log(sealObj.aa);
console.log(new Set([1,2,3]));
let 
array1 = [1,2,3,4];
for( let item  of array1) {
    console.log(`---${item}`);
}

let set1 = new Set([1,2,3,4]);
console.log(...set1);
[...set1].map(el => {
    console.log(el);
    return el
})

let sym = Symbol();
let b = sym;
console.log(sym === b);

let syms = {};
syms[Symbol.iterator] = function* (){
    yield 'a';
    yield 'b';
}
console.log(syms[Symbol.iterator]);
let ssss= Object.entries({});
console.log(ssss);
[].forEach(([a,b]) => {
    console.log(a.toString());
})

let myarr = [1,2,3,4]
let myaa = myarr.entries();
for(let item of myaa) {
    console.log(item);
}
console.log([...myaa]);

let myMap = new Map();
let oobj = {}
myMap.set(oobj, 1);
console.log(myMap.get(oobj));


let ay = {aa:'aa',bb:'bb'}, by = {aa:'aaaa',zz:'zz'}
console.log(Object.assign(ay,by));

console.log(globalThis.document);

function isNullOrEmpty(string) {
    console.log(string);
    return string == null || String(string).length == 0;
}

let mmm = isNullOrEmpty();
console.log(mmm);